const express = require("express")

const router = express.Router()
const conn = require("../mysql")

router.get("/global",(req,res)=>{
    let {Page} = req.query;
    console.log(req.query);
    let pageNum = (Page - 1) * 4;
    let result = {};
    const sql = `select * from global order by id desc limit ${pageNum},4`
    conn.query(sql,(err,data)=>{
        if(err){
            console.log(err);
        }else{
            if(data.length){
                 result = {
                     code:1,
                     data
                 }
            }else{
                result = {
                    code:0
                }
            }
        }
        // res.send(`${callback}(${JSON.stringify(result)})`);
        res.send(result);

    })
})
module.exports = router;